<?php
  class content extends admin{
    function make_extra($buff,&$buff){

      require_once KLEO_MODULES_DIR.'admin/controllers/factories/edition_list.lib.php';

      if(isset($_GET['delid'])){
	if(preg_match_all('/,/', $_GET['delid'], $matches)){
		$ids = explode(",",$_GET['delid']);
		foreach($ids as $delid){
			$delid = intval($delid);
			@$this->query("DELETE FROM ".KLEO_TABLE_PREFIX."blog WHERE id = $delid");
		}
	}
	$delid = $_GET['delid'];
	$this->query("DELETE FROM ".KLEO_TABLE_PREFIX."blog WHERE id = $delid");
      }
      if(!isset($_GET['type'])){
	$type = 'Posts';
      } else {
	$type = $_GET['type'];
      }

      $factory = new ListFactory();

      switch($_GET['type']){
	case 'Posts':
	  $pquery = "SELECT * FROM ".KLEO_TABLE_PREFIX."blog, ".KLEO_TABLE_PREFIX."users WHERE aid = uid AND type = 1 ORDER BY id DESC";
	  $captions = array(L_TITLE,L_CONTENT,L_AUTHOR,L_ACTIONS);
	  $values = array('title','resume','username','actions');
	  $sizes = array('twenty','forty','twenty','twenty');
	  $action_file = 'newpost.tpl';
	break;
	case 'Pages':
	  $pquery = "SELECT * FROM ".KLEO_TABLE_PREFIX."blog, ".KLEO_TABLE_PREFIX."users WHERE aid = uid AND type = 2 ORDER BY id DESC";
	  $captions = array(L_TITLE,L_CONTENT,L_AUTHOR,L_ACTIONS);
	  $values = array('title','resume','username','actions');
	  $sizes = array('twenty','forty','twenty','twenty');
	  $action_file = 'newpage.tpl';
	  $factory->actions = 'pages';
	break;
	case 'Feelings':
	  $pquery = "SELECT * FROM ".KLEO_TABLE_PREFIX."blog, ".KLEO_TABLE_PREFIX."users WHERE aid = uid AND type = 4 ORDER BY id DESC";
	  $captions = array(L_FEELING,L_AUTHOR,L_ACTIONS);
	  $values = array('content','username','actions');
	  $sizes = array('fifty','twenty','twenty');
	  $action_file = 'newfeeling.tpl';
	break;
	case 'Photos':
	  $pquery = "SELECT * FROM ".KLEO_TABLE_PREFIX."blog, ".KLEO_TABLE_PREFIX."users WHERE aid = uid AND type = 8 ORDER BY id DESC";
	  $captions = array(L_TITLE,L_CONTENT,L_AUTHOR,L_ACTIONS);
	  $values = array('thumb','username','actions');
	  $sizes = array('fifty','twenty','twenty');
	  $action_file = 'newphoto.tpl';
	break;
	case 'Micro':
	  $pquery = "SELECT * FROM ".KLEO_TABLE_PREFIX."blog, ".KLEO_TABLE_PREFIX."users WHERE aid = uid AND type = 11 ORDER BY id DESC";
	  $captions = array(L_FEELING,L_AUTHOR,L_ACTIONS);
	  $values = array('content','username','actions');
	  $sizes = array('fifty','twenty','twenty');
	  $action_file = 'newmicropost.tpl';
	break;
	default:
	  $pquery = "SELECT * FROM ".KLEO_TABLE_PREFIX."blog, ".KLEO_TABLE_PREFIX."users WHERE aid = uid AND type = 1 ORDER BY id DESC";
	  $captions = array(L_TITLE,L_CONTENT,L_AUTHOR,L_ACTIONS);
	  $values = array('title','resume','username','actions');
	  $sizes = array('twenty','forty','twenty','twenty');
	  $action_file = 'newpost.tpl';
	break;
      }
      if(isset($_GET['type'])){
	$buff = str_replace('value="'.$_GET['type'].'"', 'value="'.$_GET['type'].'" selected', $buff);
      }

      $factory->SetValues($captions, $values, $sizes, $pquery);
      $this->list_data = $factory->CompileList(true);
      $this->php_load('modules/admin/views/list_a.php', $factory_buff);
      $this->tpl_set("LIST", $factory_buff, $buff, $buff);

      $this->set_pagination_values(15, $pquery, null, $query);
      $this->generate_pagination_box($pagination_box, $pquery);

      $this->tpl_set(array(
	"PAGINATION_BOX" => $pagination_box,
	"ACTION_FILE" => $action_file,
	"TYPE" => $type
      ), false, $buff, $buff);


    }
  }
?>
